﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MyHealthByDesignWebsite.Models;

namespace MyHealthByDesignWebsite.Controllers
{
    public class WebPageController : Controller
    {
        //Description:  Use to get and set Web Page model data using the related view
        //Created:  Dec 2011
        //Programmer:  Bob Whiteis

        //
        // GET: /WebPage/

        public ActionResult Index()
        {
            return View();
        }

        //
        // GET: /WebPage/Details/5
        // pre-condition:  web page id has been provided
        //post-conditoin:  web page model is created and return to the details view
        public ActionResult Details(string id)
        {
            FullDataSetDataContext db = new FullDataSetDataContext();

            WebPage webPage = db.WebPages.SingleOrDefault(wp => wp.WP_webPageID == id);
           
            return View("Details", webPage);
        }

        //
        // GET: /WebPage/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /WebPage/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        
        //
        // GET: /WebPage/Edit/5
 
        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /WebPage/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /WebPage/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /WebPage/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
